package com.j2203.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class StringTools {
    @Value("${source}")
    String source;
    public  String getCode(int len){
//        System.out.println(source);
        char[] c=new char[len];

        Random r=new Random();
        for (int i = 0; i < len; i++) {
            int index = r.nextInt(source.length());
            c[i]=source.charAt(index);
        }
        return new String(c);
    }
}
